package 单例模式.多例类;

public class Multition {
    private static Multition[] array;

    private Multition(){}//私有化构造方法

    public static Multition getMultition(){
        if (array.length<=0){
            System.out.println("还没初始化，请用random方法初始化");
            return null;
        }
        return array[0];
    }

    public static void random(int count){
        if (count>0&& count<100){
            array=new Multition[count];
            for (int i = 0; i < count; i++) {
                array[i]=new Multition();
            }
            System.out.println("初始化多例类成功");
        }else {
            System.out.println("请输入0-100的整数");
        }
    }

    public void test(){
        for (Multition multition : array) {
            System.out.println(multition.hashCode());
        }
    }
}
